#include "ResourceManager.h"

ResourceManager* ResourceManager::m_pResource	   = NULL;
ResourceManager::ResourceManager(void)
{	
	SetCurrentDirectory(L"Resources/");

	//Load texture	
	AddTexture(L"CarBackground.jpg");
	AddTexture(L"Button_NewGame.png");	
	AddTexture(L"Button_HowToPlay.png");
	AddTexture(L"Button_Options.png");
	AddTexture(L"Button_Exit.png");
}


void ResourceManager::AddTexture(LPCWSTR texName)
{
	IDirect3DTexture9* m_pTmpTex;
	D3DXCreateTextureFromFile(gd3dDevice, texName, &m_pTmpTex);	
	m_buttonTextures.push_back(m_pTmpTex);
}

ResourceManager* ResourceManager::GetInstance()
{
	if (!m_pResource)	m_pResource = new ResourceManager();
	return m_pResource;
}

ResourceManager::~ResourceManager(void)
{

}

IDirect3DTexture9* ResourceManager::getTextureByID(int id)
{
	return m_buttonTextures[id];
}

void ResourceManager::Release()
{
	for(int i = 0; i < m_buttonTextures.size(); i++) 
	{
		m_buttonTextures[i]->Release();
	}
}